package services.fkgl;

import java.util.HashMap;
import java.util.List;
import com.PublicSystem;
/**
 * 个人发卡管理
 * @author duy
 *
 */
public class GrdjServices {	
	PublicSystem sys = PublicSystem.getInstance();	
	/**
	 * 下拉框选项
	 * @param lx
	 * @return
	 * @throws Exception
	 */
	public List getSelect(String lx) throws Exception {
		String sql = "select aaa103,aaa102 FROM aa10 where aaa100=?";
		List data = sys.query(sql, new Object[] {lx}, true);
		return data;
	}	
	/**
	 * 个人信息查询
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	public HashMap getgrUnitData(String id) throws Exception {
		String sql = "select * from az20 t where t.aac001=? and t.AAE036=(select max(AAE036) from az20 where aac001=?) ";		
		List data = sys.query(sql, new Object[] {id, id},true);
		HashMap map =new HashMap();
		if(data.size() > 0) {		
		    map = (HashMap)data.get(0);
		    String sql2 = "select aab001 from aca1 where aac001=?";
			List data2 = sys.query(sql2, new Object[] {id},true);
			if(data2.size() > 0 ) {			 
				HashMap obj = (HashMap)data2.get(0);
				map.put("aab001", obj.get("aab001"));				
			}
		}
		else {		
		    return null;
		}		
		return map;		
	}		
	/**
	 * 个人发卡登记信息
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	public String insertUnit(HashMap obj) throws Exception{	 
		String result = "";
		String ss = sys.callDBFuncProce("ic_az20.chk_grfk", "function", obj).toString();
		String[] str = ss.split("&");
	    result = str[0];
		if(result.equals("0")) {		
			String sss = sys.callDBFuncProce("ic_az20.set_fkdj", "function", obj).toString();
			String[] res = sss.split("&");
			result = res[0];		
	        return result;		
		}
		else {				
		    return result;
		}		
	} 
}
